#include "Grid.h"

Grid::Grid(int g, float e)
{	
	Variables::granularity = g;
	Variables::threshold = e;

	this->increment = (float)2 / (float)g;

	initializeCells();
}

void Grid::initializeCells() {
	grid.resize(Variables::granularity);
	for (int i = 0; i < grid.size(); i++) {
		grid[i].resize(Variables::granularity);
	}

	float xValue = -1;
	float YValue = -1;

	for (int x = 0; x < Variables::granularity; x++) {

		for (int y = 0; y < Variables::granularity; y++) {

			grid[x][y] = new Cell(xValue, YValue, increment);
			
			YValue += increment;
		}
		YValue = -1;
		xValue += increment;
	}
}

ostream& operator<<(ostream& os, Grid* g) {
			for (int x = 0; x < Variables::granularity; x++) {

				for (int y = 0; y < Variables::granularity; y++) {

					os << g->grid[x][y];

				}
			}
}
